package fatworm.storage.types;

import fatworm.query.constant.*;
import fatworm.storage.table.*;

public class JBytes extends SType
{
    byte[] val;

    public JBytes()
    {
        this(null);
    }
    public JBytes(byte[] val)
    {
        this.val = val;
    }
    @Override
    public void fromBytes(byte[] bytes)
    {
        if (bytes[0] == NULLFLAG)
            val = null;
        else
        {
            System.arraycopy(bytes, 1, val, 0, bytes.length - 1);
        }
    }
    @Override
    public byte[] toBytes()
    {
        if (val == null)
            return new byte[]{NULLFLAG};
        byte[] res = new byte[val.length + 1];
        res[0] = NOTNULLFLAG;
        System.arraycopy(val, 0, res, 1, val.length);
        return res;
    }
    @Override
    public int length()
    {
        // TODO Auto-generated method stub
        return 0;
    }
    @Override
    public byte[] toBytesAsVID(VID vid)
    {
        // TODO Auto-generated method stub
        return null;
    }
    @Override
    public int lengthAsVID()
    {
        // TODO Auto-generated method stub
        return 0;
    }
    @Override
    public int getType()
    {
        // TODO Auto-generated method stub
        return 0;
    }
    @Override
    public Constant toConstant()
    {
        // TODO Auto-generated method stub
        return null;
    }
    @Override
    public void fromConstant(Constant c)
    {
        // TODO Auto-generated method stub
    }
    @Override
    public SType newInstance()
    {
        // TODO Auto-generated method stub
        return null;
    }
    @Override
    public SType copy()
    {
        // TODO Auto-generated method stub
        return null;
    }
}
